import Mock from 'mockjs'

function getVersionList() {
  const json = {code: 200, success: true, msg: '操作成功'};
  const list = [];
  list.push(
    {
      id: '1',
      version_id:'10701',
      version_name:'甘棠政务1.7.1',
      device_type: 'Androd',
      update_force:'是',
      update_silence:'否',
      version_deny:'否',
      create_time: '2021-06-02 18:56:08',
      create_user:'雷璐',
      update_time:'2021-06-03 19:31:36',
      update_user:'许东',
    },
    {
      id: '2',
      version_id:'10701',
      version_name:'甘棠政务1.7.1',
      device_type: 'Androd',
      update_force:'是',
      update_silence:'否',
      version_deny:'否',
      create_time: '2021-06-02 18:56:08',
      create_user:'雷璐',
      update_time:'2021-06-03 19:31:36',
      update_user:'许东',
    }
  );
  json.data = {
    total: 10,
    size: 10,
    current: 1,
    searchCount: true,
    pages: 1,
    records: list,
  };
  return json;
}

function getVersionDetail() {
  const json = {code: 200, success: true, msg: '操作成功'};
  json.data = {
    id: '1',
    version_id:'10701',
    version_name:'甘棠政务1.7.1',
    device_type: 'Androd',
    update_force:1,
    update_silence:0,
    version_deny:0,
    create_time: '2021-06-02 18:56:08',
    create_user:'雷璐',
    update_time:'2021-06-03 19:31:36',
    update_user:'许东',
  };
  return json;
}

function versionSuccess() {
  return {code: 200, success: true, msg: '操作成功'};
}

export default ({mock}) => {
  if (!mock) return;
  Mock.mock('/api/blade-system/version/list', 'get', getVersionList);

  Mock.mock('/api/blade-system/version/detail', 'get', getVersionDetail);

  Mock.mock('/api/blade-system/version/submit/', 'post', versionSuccess);

  Mock.mock('/api/blade-system/version/remove/', 'post', versionSuccess);

}
